package operations;

import book.Booklist;

import java.util.Scanner;
public class ReturnOperation implements Operation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("归还图书......");
        Scanner scanner = new Scanner(System.in);
        System.out.printf("请输入你归还的书的书名：");
        String name = scanner.nextLine();

        for (int i = 0; i < booklist.getUesdSize(); i++){
            if (booklist.getBook(i).getName().equals(name)){
                if (booklist.getBook(i).isIsborrowed()){
                    System.out.println("归还成功!!!");
                    booklist.getBook(i).setIsborrowed(false);
                    return;
                }
            }
        }
        System.out.println("没有你要归还的书...");
    }
}
